// https://nuxt.com/docs/api/configuration/nuxt-config
import { fileURLToPath } from "node:url";
import { AntDesignVueResolver } from "unplugin-vue-components/resolvers";
import Components from "unplugin-vue-components/vite";
import Icons from "unplugin-icons/vite";
import IconsResolver from "unplugin-icons/resolver";

export default defineNuxtConfig({
  compatibilityDate: "2024-12-01",
  runtimeConfig: {
    SecretId: process.env.SECRET_ID,
    SecretKey: process.env.SECRET_KEY,
    DB_HOST: process.env.DB_HOST,
    DB_USER: process.env.DB_USER,
    DB_DATABASE: process.env.DB_DATABASE,
    DB_PASSWORD: process.env.DB_PASSWORD,
    public: {
      BUCKET: process.env.BUCKET,
      REGION: process.env.REGION,
    },
  },
  modules: [
    "@pinia/nuxt",
    "pinia-plugin-persistedstate/nuxt",
    "unplugin-icons/nuxt",
  ],
  devtools: { enabled: true },
  alias: {
    "~": fileURLToPath(new URL(".", import.meta.url)),
    "@": fileURLToPath(new URL(".", import.meta.url)),
  },
  vite: {
    plugins: [
      Components({
        resolvers: [
          AntDesignVueResolver({
            importStyle: false, // 禁用自动导入样式，使用全局样式导入
          }),
          IconsResolver({
            prefix: "icon",
            enabledCollections: ["ep", "ant-design", "mdi"],
          }),
        ],
      }),
      Icons({
        autoInstall: true,
      }),
    ],
    esbuild: {
      drop:
        process.env.NODE_ENV === "production" ? ["console", "debugger"] : [],
    },
    build: {
      minify: "esbuild",
      chunkSizeWarningLimit: 500,
      cssCodeSplit: true,
    },
    ssr: {
      noExternal: ["ant-design-vue"],
    },
  },
});
